<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Promise-面试题</title>
</head>

<body>
  <script>
    var p1 = new Promise(function(reslove) {
      console.log(1)
      reslove()
    })

    p1.then(function() {
      console.log(2)
    }).then(function() {
      console.log(3)
    })

    console.log(4)

    // 结果依次是 1 4 3 2

    var p2 = new Promise(function(reslove) {
      reslove(Promise.reject("error"))
    })

    console.log(p2)     // reject
    
  </script>
</body>

</html>